package com.example.controller.admin;

import com.example.common.Result;
import com.example.entity.DTO.ClassDetailDTO;
import com.example.entity.Class;
import com.example.entity.Department;
import com.example.service.admin.ClassService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin")
public class ClassController {
    @Resource
    private ClassService classService;

    /**
     * 获取全部班级详细信息
     */
    @GetMapping("/selectAllClass")
    public Result selectAllClass(@RequestParam(defaultValue = "") String className,
                                 @RequestParam(defaultValue = "") String majorName,
                                 @RequestParam(defaultValue = "") String deptName) {
        List<ClassDetailDTO> classDetailDTOS = classService.selectAllClass(className, majorName, deptName);
        return Result.success(classDetailDTOS);
    }

    /**
     * 添加班级
     */
    @PostMapping("/addClass")
    public Result addClass(@RequestBody Class classData) {
        classService.addClass(classData);
        return Result.success();
    }

    /**
     * 更新班级信息
     */
    @PutMapping("/updateClass")
    public Result updateClass(@RequestBody Class classData) {
        classService.updateClass(classData);
        return Result.success();
    }
}
